From 64acf06829a173e92c18a2c94d45132d1d6f092a Mon Sep 17 00:00:00 2001 From: "mafetter@fleming.research" Date: Tue, 15 Mar 2005 08:15:00 +0000 Subject: [PATCH] bitkeeper revision 1.1236.33.1 (42369984aBV0c2ogV4Bh1SA0FxWSLA) Added support for mapping other domain's memory from a privileged shadowed domain. Should hopefully enable a shadowed dom0 to start up other domains. Signed-off-by: michael.fetterman@cl.cam.ac.uk --- xen/arch/x86/mm.c | 2 -- xen/arch/x86/shadow.c | 6 +++--- xen/include/asm-x86/shadow.h | 30 +++++++++++++++++++++++++++--- xen/include/xen/perfc_defn.h | 1 + 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 0a7be0e313..69c55a185f 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -1858,8 +1858,6 @@ int do_mmu_update( break; #endif /* __x86_64__ */ default: - printk("do_mmu_update writable update: ma=%p val=%p\n", - req.ptr, req.val); if ( likely(get_page_type(page, PGT_writable_page)) ) { if ( shadow_mode_enabled(d) ) diff --git a/xen/arch/x86/shadow.c b/xen/arch/x86/shadow.c index b32438f497..ea690b94ff 100644 --- a/xen/arch/x86/shadow.c +++ b/xen/arch/x86/shadow.c @@ -1197,7 +1197,7 @@ void shadow_map_l1_into_current_l2(unsigned long va) { l1pte_propagate_from_guest(d, gpl1e[i], &spl1e[i]); if ( spl1e[i] & _PAGE_PRESENT ) - get_page_from_l1e(mk_l1_pgentry(spl1e[i]), d); + shadow_get_page_from_l1e(mk_l1_pgentry(spl1e[i]), d); } } } @@ -1503,7 +1503,7 @@ static u32 remove_all_write_access_in_ptpage( unsigned long new = old & ~_PAGE_RW; if ( is_l1_shadow ) - get_page_from_l1e(mk_l1_pgentry(new), d); + shadow_get_page_from_l1e(mk_l1_pgentry(new), d); count++; pt[i] = new; @@ -1724,7 +1724,7 @@ void __shadow_sync_all(struct domain *d) unsigned long opte = *ppte; unsigned long npte = opte & ~_PAGE_RW; - get_page_from_l1e(mk_l1_pgentry(npte), d); + shadow_get_page_from_l1e(mk_l1_pgentry(npte), d); *ppte = npte; put_page_from_l1e(mk_l1_pgentry(opte), d); diff --git a/xen/include/asm-x86/shadow.h b/xen/include/asm-x86/shadow.h index 89c09d004f..70abf82e8a 100644 --- a/xen/include/asm-x86/shadow.h +++ b/xen/include/asm-x86/shadow.h @@ -213,6 +213,30 @@ extern int shadow_status_noswap; #endif +/************************************************************************/ + +static inline int +shadow_get_page_from_l1e(l1_pgentry_t l1e, struct domain *d) +{ + int res = get_page_from_l1e(l1e, d); + struct domain *owner; + + if ( unlikely(!res) && IS_PRIV(d) && !shadow_mode_translate(d) && + (owner = page_get_owner(pfn_to_page(l1_pgentry_to_pfn(l1e)))) && + (d != owner) ) + { + res = get_page_from_l1e(l1e, owner); + printk("tried to map page from domain %d into shadow page tables " + "of domain %d; %s\n", + owner->id, d->id, res ? "success" : "failed"); + } + + if ( unlikely(!res) ) + perfc_incrc(shadow_get_page_fail); + + return res; +} + /************************************************************************/ static inline void @@ -257,7 +281,7 @@ __guest_set_l2e( if ( (old_hl2e ^ new_hl2e) & (PAGE_MASK | _PAGE_PRESENT) ) { if ( new_hl2e & _PAGE_PRESENT ) - get_page_from_l1e(mk_l1_pgentry(new_hl2e), ed->domain); + shadow_get_page_from_l1e(mk_l1_pgentry(new_hl2e), ed->domain); if ( old_hl2e & _PAGE_PRESENT ) put_page_from_l1e(mk_l1_pgentry(old_hl2e), ed->domain); } @@ -574,7 +598,7 @@ validate_pte_change( if ( (old_spte ^ new_spte) & (PAGE_MASK | _PAGE_RW | _PAGE_PRESENT) ) { if ( new_spte & _PAGE_PRESENT ) - get_page_from_l1e(mk_l1_pgentry(new_spte), d); + shadow_get_page_from_l1e(mk_l1_pgentry(new_spte), d); if ( old_spte & _PAGE_PRESENT ) put_page_from_l1e(mk_l1_pgentry(old_spte), d); } @@ -1081,7 +1105,7 @@ shadow_set_l1e(unsigned long va, unsigned long new_spte, int create_l1_shadow) if ( (old_spte ^ new_spte) & (PAGE_MASK | _PAGE_RW | _PAGE_PRESENT) ) { if ( new_spte & _PAGE_PRESENT ) - get_page_from_l1e(mk_l1_pgentry(new_spte), d); + shadow_get_page_from_l1e(mk_l1_pgentry(new_spte), d); if ( old_spte & _PAGE_PRESENT ) put_page_from_l1e(mk_l1_pgentry(old_spte), d); } diff --git a/xen/include/xen/perfc_defn.h b/xen/include/xen/perfc_defn.h index 895c50e09a..5e38e38924 100644 --- a/xen/include/xen/perfc_defn.h +++ b/xen/include/xen/perfc_defn.h @@ -43,6 +43,7 @@ PERFCOUNTER_CPU(shadow_status_miss, "missed shadow cache" ) PERFCOUNTER_CPU(shadow_status_hit_head, "hits on head of bucket" ) PERFCOUNTER_CPU(check_pagetable, "calls to check_pagetable" ) PERFCOUNTER_CPU(check_all_pagetables, "calls to check_all_pagetables" ) +PERFCOUNTER_CPU(shadow_get_page_fail, "shadow_get_page_from_l1e fails" ) PERFCOUNTER_CPU(shadow_sync_all, "calls to shadow_sync_all") PERFCOUNTER_CPU(shadow_make_snapshot, "snapshots created") -- 2.30.2